﻿#主要用于插入注释
import sublime, sublime_plugin,os,sys,shutil,re

def escape(str):
    return str.replace('$', '\$').replace('{', '\{').replace('}', '\}')

 #view.run_command('insert_snippet',{'contents': "jahahahaha"})
 
class testCommand(sublime_plugin.TextCommand):
	def run(self, edit):
		scope_name = self.view.scope_name(self.view.sel()[0].end()) 
		print (scope_name)
		scope_name = 'source.python'
		res = re.search('\\bsource\\.([a-z+\-]+)', scope_name)
		sourceLang = res.group(1) if res else 'js'
		print (res)
		print (sourceLang)

		print (re.search('^\\s*--((?!\\[|-).*)$', "--[[dsadsads").group(1))
		#print (re.search('^\\s*\\*', "/*sd*"))
		# '\\s*\\*\\/\\s*$'
		#print (re.sub(r'/\*.*?\*/', 'ss', "/*\\n*8jaksdl*/"))
		#print (escape(re.sub('(\\s*\]\]\\s*$)', '', "--[[asdssasdasd]]")))
		#identifier = '[a-zA-Z_$][a-zA-Z_$0-9]*'
		#fnOpener = '(?:'+ r'function[\s*]*(?:' + identifier + r')?\s*'+ '|'+ '(?:' + identifier + r'|\(.*\)\s*=>)'+ '|'+ '(?:' + identifier + r'\s*\(.*\)\s*\{)'+ ')'
		#print (fnOpener)
		#opener = re.search(fnOpener, ' /99fsdfdsffunctio(a,b)')
		#print (opener.start())
		#print (re.findall('[()]', 'd[dd(ddd)'))
